package company.kedaxunfei;

import java.util.HashSet;
import java.util.Scanner;

public class Ke2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }

        int i = 0;
        HashSet<Integer> dict = new HashSet<>();
        boolean isSwap = false;
        while (i < n - 1) {
            System.out.println(dict);
            int base = nums[i];
            if (dict.contains(base)) {
                i++;
                continue;
            }
            isSwap = false;
            int p = i, q = n - 1;
            while (p != q) {
                while (nums[q] >= base && p < q)
                    q--;
                while (nums[p] <= base && p < q)
                    p++;
                if (p < q) {
                    swap(nums, p, q);
                    isSwap = true;
                }
            }
            swap(nums, i, p);
            print(nums);
            dict.add(base);
            if (!isSwap)
                i++;
        }
    }

    private static void swap(int[] nums, int i, int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }

    private static void print(int[] nums) {
        for (int num : nums) {
            System.out.print(num + " ");
        }
        System.out.println();
    }
}
